"use strict";
cc._RF.push(module, '154d7RPD6RGObdA1nWD8hvD', 'autoFixed');
// Script/gameEvent/autoFixed.ts

// Learn TypeScript:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/typescript.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
Object.defineProperty(exports, "__esModule", { value: true });
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var Constant_1 = require("../constant/Constant");
var FixScreen = /** @class */ (function (_super) {
    __extends(FixScreen, _super);
    function FixScreen() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.left = null;
        _this.right = null;
        _this.speed = 0.5;
        return _this;
        // update (dt) {}
    }
    /**
     * 自动组合两个方块
     */
    FixScreen.prototype.autoFixed = function () {
        this.stopAnimation();
        var R_M = cc.moveTo(this.speed, new cc.Vec2(this.right.width / 2, this.right.y));
        var L_M = cc.moveTo(this.speed, new cc.Vec2(-this.left.width / 2, this.right.y));
        var spaw_R = cc.spawn(R_M, cc.rotateTo(this.speed, 0, 360));
        var spaw_L = cc.spawn(L_M, cc.rotateTo(this.speed, 0, -360));
        this.right.runAction(spaw_R);
        this.left.runAction(spaw_L);
    };
    /**
     * 方块总体左移
     */
    FixScreen.prototype.allToLeft = function () {
        this.stopAnimation();
        var LtoLeft = cc.moveTo(this.speed, new cc.Vec2(-(Constant_1.Constant.SCREEN.width - this.right.width) / 2, this.right.y));
        var RtoLeft = cc.moveTo(this.speed, new cc.Vec2(-(Constant_1.Constant.SCREEN.width / 2 - (this.left.width + this.left.width / 2)), this.left.y));
        var spaw_R = cc.spawn(RtoLeft, cc.rotateTo(this.speed, 0, 180));
        var spaw_L = cc.spawn(LtoLeft, cc.rotateTo(this.speed, 0, -180));
        this.right.runAction(spaw_R);
        this.left.runAction(spaw_L);
    };
    /**
     * 方块总体右移
     */
    FixScreen.prototype.allToRight = function () {
        this.stopAnimation();
        // let fixScreen: FixScreen = cc.find("Canvas/GameObject").getComponent(FixScreen);
        var RtoRgiht = cc.moveTo(this.speed, new cc.Vec2((Constant_1.Constant.SCREEN.width - this.left.width) / 2, this.left.y));
        var LtoRight = cc.moveTo(this.speed, new cc.Vec2((Constant_1.Constant.SCREEN.width / 2 - (this.right.width + this.left.width / 2)), this.left.y));
        var spaw_R = cc.spawn(RtoRgiht, cc.rotateTo(this.speed, 0, 180));
        var spaw_L = cc.spawn(LtoRight, cc.rotateTo(this.speed, 0, -180));
        this.right.runAction(spaw_R);
        this.left.runAction(spaw_L);
    };
    /**
     * 分开移动
     */
    FixScreen.prototype.splitOver = function () {
        this.stopAnimation();
        var R_R = cc.moveTo(this.speed, new cc.Vec2((Constant_1.Constant.SCREEN.width - this.right.width) / 2, this.right.y));
        var L_L = cc.moveTo(this.speed, new cc.Vec2(-(Constant_1.Constant.SCREEN.width - this.left.width) / 2, this.left.y));
        var spaw_R = cc.spawn(R_R, cc.rotateTo(this.speed, 0, 180));
        var spaw_L = cc.spawn(L_L, cc.rotateTo(this.speed, 0, -180));
        this.right.runAction(spaw_R);
        this.left.runAction(spaw_L);
    };
    /**
     * 停止所有进行的动画
     */
    FixScreen.prototype.stopAnimation = function () {
        this.left.stopAllActions();
        this.right.stopAllActions();
    };
    FixScreen.prototype.start = function () {
        var width = this.left.width = Constant_1.Constant.SCREEN.width / 7;
        this.left.height = width;
        this.right.width = width;
        this.right.height = width;
        this.right.getComponent(cc.BoxCollider).size.width = width * 0.8;
        this.left.getComponent(cc.BoxCollider).size.width = width * 0.8;
        this.autoFixed();
    };
    __decorate([
        property(cc.Node)
    ], FixScreen.prototype, "left", void 0);
    __decorate([
        property(cc.Node)
    ], FixScreen.prototype, "right", void 0);
    __decorate([
        property
    ], FixScreen.prototype, "speed", void 0);
    FixScreen = __decorate([
        ccclass
    ], FixScreen);
    return FixScreen;
}(cc.Component));
exports.default = FixScreen;

cc._RF.pop();